package game.entity.action;

import edu.monash.fit2099.engine.Action;
import edu.monash.fit2099.engine.Actor;
import edu.monash.fit2099.engine.GameMap;
import edu.monash.fit2099.engine.Ground;
import game.CoinPoint;
import game.entity.ground.Bush;
import game.entity.item.Fruit;
import game.util.RandomUtil;

public class SearchAction extends Action {

    private int findFruitRate = 60;
    private Ground ground;

    public SearchAction(int findFruitRate, Ground ground) {
        this.findFruitRate = findFruitRate;
        this.ground = ground;
    }
    @Override
    public String execute(Actor actor, GameMap map) {
        if(ground.hasFruit() && RandomUtil.shotOn(findFruitRate)){
            Fruit fruit = ground.getFruits().get(0);
            actor.addItemToInventory(fruit);
            ground.removeFruit(fruit);
            CoinPoint.addPoints(10,"searching fruit successfully");
            return "you are searching, found fruits successfully!";
        }else{
            return "you are searching, but found nothing.";
        }

    }

    @Override
    public String menuDescription(Actor actor) {
        return actor + " search the "+ ground.getClass().getName();
    }
}
